package com.onLineCar.vehicle.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.onLineCar.vehicle.entity.TblOrder;
import com.onLineCar.vehicle.entity.request.Reconciliation;
import com.onLineCar.vehicle.entity.request.ReqDriverPreemptOrder;
import com.onLineCar.vehicle.entity.request.RequestUpdate;
import com.onLineCar.vehicle.entity.request.TblOrderRequest;
import com.onLineCar.vehicle.entity.request.driver.DriverOrderRequest;
import com.onLineCar.vehicle.entity.request.user.UserOrderRequest;

import java.util.List;


/**
 * <p>
 * 订单表 服务类
 * </p>
 *
 * @author Xinke_Li
 * @since 2023-12-11
 */
public interface ITblOrderService extends IService<TblOrder> {

    /**
     * 用户下单
     */
    String placeAnOrder(TblOrder tblOrder);

    /**
     * 订单列表
     */
    IPage<TblOrder> selectOrder(TblOrderRequest tblOrderRequest);

    /**
     * 查看订单详情
     */
    TblOrder selectOrderNumber(String orderNumber);

    /**
     * 删除订单
     */
    int deleteOrderNumber(String orderNumber);

    /**
     * 根据城市查询订单
     */
    List<TblOrder> selectByCityCode(Long cityCode);

    /**
     * 根据用户id查询订单
     */
    TblOrder selectByUserId(Long id);

    /**
     * 根据司机id查询订单
     */
    TblOrder selectByDriverId(Integer driverId);

    /**
     * 司机接单
     */
    int driverTakeOrder(TblOrder tblOrder);

    /**
     * 根据訂單狀態查询订单
     */
    List<TblOrder> selectList();

    /**
     * 查询所有的已结束订单以及已取消订单
     */
    List<TblOrder> selectAllCloseOrder();

    void updateOrderStateByOrderNumber(RequestUpdate requestUpdate);

    /**
     * 用户下单2,分库分表
     */
    String userPlacesAnOrder(TblOrder tblOrder);

    /**
     * 根据订单编号查询当前用户的订单详情
     */
    TblOrder selectOrderByOrderNumber(String orderNumber);

    /**
     * 生成订单编号
     */
    String createAnOrderNumber();

    /**
     * redisson抢单
     */
    boolean redissonDriverPreempt(ReqDriverPreemptOrder reqDriverPreemptOrder);

    /**
     * 疑义账单
     */
    int updatebill(Reconciliation reconciliation);

    /**
     * 用户取消订单
     */
    int cancelOrder(Reconciliation reconciliation);

    /**
     * 根据用户ID查询订单详情
     */
    TblOrder servletByInfoId(Integer passengerInfoId);

    /**
     * 用户查看自己的所有订单
     */
    IPage<TblOrder> selectAllByUserId(UserOrderRequest userOrderRequest);

    /**
     * 司机查看自己的所有订单
     */
    IPage<TblOrder> selectAllByDriverId(DriverOrderRequest driverOrderRequest);

    List<TblOrder> selectOrderByDriverId(Integer driverId);

    /**
     * 根据订单号修改状态
     */
    String updateUserReach(RequestUpdate requestUpdate);

}
